package com.scofevil.net;

import java.net.MalformedURLException;
import java.net.URL;

public class Test {
	public static void main(String[] args) {
		try {
			URL imooc = new URL("http://www.imooc.com");
			URL url = new URL(imooc, "/index.html?username=tom#test");
			System.out.println("协议:" + url.getProtocol());
			System.out.println("主机:" + url.getHost());

			System.out.println("端口:" + url.getPort());
			System.out.println("" + url.getPath());
			System.out.println("" + url.getRef());
			System.out.println("" + url.getRef());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
}
